package book;

public class BookList { //定义书架
    private Book[] books = new Book[10]; //定义能放10本书
//    private Book[] books;
//    public BookList(){ //无参构造，调用BookList类时会自动调用该方法，为books赋空间
//        this.books = new Book[10];
//    }

    public BookList(){ //默认书架上存者四本书
        this.books[0] = new Book("三国演义","罗贯中",21,"小说");
        this.books[1] = new Book("西游记","吴承恩",22,"小说");
        this.books[2] = new Book("红楼梦","曹雪芹",23,"小说");
        this.books[3] = new Book("水浒传","施耐庵",24,"小说");
        this.usedSize = 4;
    }
    public Book getBook(int pos){ //得到下标为pos位置的书
        return books[pos];
    }
    public void setBook(int pos,Book book){ //将一个书存放到下标为pos的位置
        books[pos] = book;
    }

    private int usedSize; //计数器，计算当前放到书的个数，默认值是0

    public int getUsedSize() {
        return usedSize;
    }

    public void setUsedSize(int usedSize) {
        this.usedSize = usedSize;
    }

}

